import "dotenv/config";
import inquirer from "inquirer";
import { questions } from "./questions/login";
import { login } from "./utils/login";
import { processToken } from "./utils/processToken";
import { readFileByType } from "../utils/util";
import { showMoney } from "./utils/showMoney";

(async () => {
  await inquirer.prompt(questions).then(async (answers) => {
    const randomNum = readFileByType("code")
    const res = await login(
      answers.username,
      answers.password,
      answers.code,
      randomNum
    );
    if (res) {
      processToken(res);
      await showMoney()
    } else {
      console.log('用户名或密码错误!');
    }
  });
})();
